
#ifndef __AUTO_LOCK_WRITE_H
#define __AUTO_LOCK_WRITE_H

#include "APRRWMutex.h"

class APRAutoLockWrite
{
   public:
      APRAutoLockWrite(APRRWMutex *i_rwmutex)
      {
         _rwmutex = i_rwmutex;
         _rwmutex->lockWrite();
      }
      ~APRAutoLockWrite()
      {
         if (_rwmutex) _rwmutex->unlock();
      }
      void TurnOff()
      {
         _rwmutex->unlock();
         _rwmutex = NULL;
      }
   private:
      APRRWMutex *_rwmutex;
};

#endif
